package com.scpii.universal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.entity.AttributeTab;
import com.scpii.universal.hibernate.entity.PageAttributeTab;
import com.scpii.universal.hibernate.intface.BaseInterface;
import com.scpii.universal.util.SpringBeanFactory;

public class PageAttributeTabService implements BaseInterface<PageAttributeTab> {
	private static final Logger log = LoggerFactory
			.getLogger(PageAttributeTabService.class);
//	private BaseDao<PageAttributeTab> pageAttributeTabDao = SpringBeanFactory.pageAttributeTabDao;
	private BaseDao<PageAttributeTab> pageAttributeTabDao;
	
	public PageAttributeTab get(Integer id) throws Exception {
		return pageAttributeTabDao.get(id);
	}

	public List<PageAttributeTab> getAll() throws Exception {
		return pageAttributeTabDao.getAll();
	}

	public PageAttributeTab get(String propertyName, Object value) throws Exception {
		return null;
	}

	public List<PageAttributeTab> getList(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public Long getTotalCount() throws Exception {
		return null;
	}

	public void save(PageAttributeTab obj) throws Exception {

	}

	public void update(PageAttributeTab obj) throws Exception {

	}

	public void delete(PageAttributeTab obj) throws Exception {

	}

	public void delete(Integer id) throws Exception {

	}

	public List<PageAttributeTab> hqlGetList(String hql, Map<String, Object> argsMap)
			throws Exception {
		return pageAttributeTabDao.hqlGetList(hql, argsMap);
	}

	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		pageAttributeTabDao.hqlUpdate(namedHqlQuery, argsMap);
	}

	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		return pageAttributeTabDao.hqlGetNums(namedHqlQuery, argsMap);
	}

	public List<PageAttributeTab> sqlGetList(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return pageAttributeTabDao.sqlGetList(sqls, argsMap);
	}

	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		pageAttributeTabDao.sqlUpdate(sqls, argsMap);
	}

	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return pageAttributeTabDao.sqlGetNum(sqls, argsMap);
	}
	
	/**
	 * 根据页面ID，获得在页面上显示的属性列表（以顺序排序）
	 * @param pageId
	 * @return
	 * @throws Exception
	 * @author 甘建新
	 * 2012-7-16下午05:25:12
	 */
	public List<PageAttributeTab> getAttributeListOnPage(int pageId)throws Exception{
//		List<AttributeTab> attributeList = new ArrayList<AttributeTab>();
		List<PageAttributeTab> pageAttributeList = new ArrayList<PageAttributeTab>();
		Map<String,Object> argsMap = new HashMap<String, Object>();
		argsMap.put("pageId", pageId);
		//取得页面与属性之间的中间表
		pageAttributeList = this.hqlGetList("GET_PAGE_ATTRIBUTES", argsMap);
//		if (pageAttributeList!=null && pageAttributeList.size()>0) {
//			for (PageAttributeTab pageAttributeTab : pageAttributeList) {
//				int attributeId = pageAttributeTab.getIntResourceId();
//				//取得属性信息
//				AttributeTab attribute = (new AttributeTabService()).get(attributeId);
//				//添加到属性列表中
//				attributeList.add(attribute);
//			}
//		}
		return pageAttributeList;
	}

	//Setter
	public void setPageAttributeTabDao(BaseDao<PageAttributeTab> pageAttributeTabDao) {
		this.pageAttributeTabDao = pageAttributeTabDao;
	}
	
	
}